package ua.com.fesvlast.hotel.model.commands;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;



import ua.com.fesvlast.hotel.controller.managers.ConfigurationManager;
import ua.com.fesvlast.hotel.model.enteties.Users;

public class LogOutCommand implements ICommand{

	@Override
	public String execute(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
			String page =null;
			Users user =(Users)request.getSession().getAttribute("currentUser");
			
			if(user!=null){
				request.getSession().invalidate();
				page=ConfigurationManager.getInstance().getProperty(ConfigurationManager.INDEX_PAGE);
			}else{
				page=ConfigurationManager.getInstance().getProperty(ConfigurationManager.LOGIN_PAGE_PATH);
			}
		
		
		return page;
	}

}
